list_of_packages <- c("tidyverse", "plotly", "here", "signal", "DT")
new_packages <- list_of_packages[!(list_of_packages %in% installed.packages()[,"Package"])]
if(length(new_packages)) install.packages(new_packages)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.3 ✓ purrr 0.3.4
## ✓ tibble 3.1.0 ✓ dplyr 1.0.4
## ✓ tidyr 1.1.2 ✓ stringr 1.4.0
## ✓ readr 1.4.0 ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(here)
## here() starts at /home/francisko/coding/r/flight-path-experiment
library(signal)
##
## Attaching package: 'signal'
## The following object is masked from 'package:plotly':
##
## filter
## The following object is masked from 'package:dplyr':
##
## filter
## The following objects are masked from 'package:stats':
##
## filter, poly
library(DT)
b195_t1 <- readr::read_csv(here::here("unpaired-points", "b195-t1-unpaired-points-xyz.csv"))
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## x_1 = col_double(),
## y_1 = col_double(),
## z_1 = col_double()
## )
butterworth_filter <-
butter(n = 4, # order
W = 0.5, # critical frequency
type = "low")
I used the same parameters as Camille.
b195_t1 %>%
tidyr::drop_na() %>%
dplyr::mutate(x_butterworth = signal::filter(butterworth_filter, x_1),
y_butterworth = signal:: filter(butterworth_filter, y_1),
z_butterworth = signal::filter(butterworth_filter, z_1)) -> b195_t1_filtered
b195_t1_filtered %>%
DT::datatable(extensions = 'Buttons',
options = list(dom = 'Blfrtip',
buttons = c('copy', 'csv', 'excel', 'pdf', 'print'),
lengthMenu = list(c(10,25,50,-1),
c(10,25,50,"All"))))
plot_ly(data = b195_t1_filtered,
type = "scatter3d",
name = "Raw tracking",
x = b195_t1_filtered$x_1 ,
y = b195_t1_filtered$y_1,
z = b195_t1_filtered$z_1,
mode = "lines",
line = list(color = "steelblue")) %>%
add_trace(
type = "scatter3d",
name = "Tracking smoothed usind butterworth filter",
x = b195_t1_filtered$x_butterworth,
y = b195_t1_filtered$y_butterworth,
z = b195_t1_filtered$z_butterworth,
mode = "lines",
line = list(color = "firebrick")
)